package ln.fxspringarchetype.model;

import org.apache.logging.log4j.util.Strings;

import java.util.Date;

public class Student {
    private int id;
    private String name;
    private Date birthday;
    private byte[] photo;
    private Gender gender;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public byte[] getPhoto() {
        return photo;
    }

    public void setPhoto(byte[] photo) {
        this.photo = photo;
    }

    public Gender getGender() {
        return gender;
    }

    public void setGender(Gender gender) {
        this.gender = gender;
    }

    /**
     * 性别枚举
     */
    public enum Gender {
        MALE("男"), FEMALE("女");

        private final String value;

        Gender(String value) {
            this.value = value;
        }

        /**
         * 根据性别名称字符串返回枚举值的便利方法
         *
         * @param genderName
         * @return
         */
        public static Gender of(String genderName) {
            if (Strings.isEmpty(genderName)) {
                return Gender.MALE;
            }
            return genderName.equals("男") ? Gender.MALE : Gender.FEMALE;
        }

        public String getValue() {
            return value;
        }
    }
}
